package com.zjitc.controller;

import com.zjitc.InsertSql;
import com.zjitc.common.ServerResponse;
import com.zjitc.model.Cat;
import com.zjitc.service.CatService;
import com.zjitc.service.UserService;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpSession;
import javax.swing.text.View;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.InternalResourceView;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/4/19 14:04
 * @description:
 */
@Controller
@RequestMapping("/cat")
public class CatController {

  @Autowired
  private CatService catService;

  @RequestMapping(value = "/CatSpecies")
  public ModelAndView findByCatSpecies(@RequestParam(name = "CatSpecies")String catSpecies,HttpSession session) {
    List<Cat> list =  catService.findByCatSpecies(catSpecies);
    ModelAndView view = new ModelAndView();
    view.addObject("CatSpeciesList",list);
    view.setView(new InternalResourceView("catSpecies/sold.jsp"));
    return view;
  }

  @RequestMapping(value = "/insert")
  public ModelAndView insert() {
    InsertSql insertSql = new InsertSql();
    insertSql.insert();
    System.out.println("ojbk");
    ModelAndView mv = null;
    return mv;
  }

  @RequestMapping(value = "/addCats")
  public void addCats(){
    catService.addCats();
  }

  
}
